package org.dromara.system.controller;


import com.mybatisflex.core.paginate.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.dromara.system.pojo.bo.SysClientBO;
import org.dromara.system.pojo.qo.SysClientQO;
import org.dromara.system.pojo.vo.SysClientVO;
import org.dromara.system.service.SysClientService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统授权表 控制层。
 *
 * @author mkj
 * @since 2024-07-20
 */
@Tag(name = "系统授权表接口")
@RequiredArgsConstructor
@RestController
@RequestMapping("SysClient")
public class SysClientController {

    private final SysClientService sysClientService;

    /**
     * 新增
     *
     * @param sysClientBO 表单
     * @return {@code true} 添加成功，{@code false} 添加失败
     */
    @PostMapping("add")
    @Operation(description = "新增")
    public boolean add(@RequestBody SysClientBO sysClientBO) {
        return sysClientService.add(sysClientBO);
    }

    /**
     * 根据主键删除
     *
     * @param id 主键
     * @return {@code true} 删除成功，{@code false} 删除失败
     */
    @DeleteMapping("remove/{id}")
    @Operation(description = "根据主键删除")
    public boolean remove(@PathVariable Long id) {
        return sysClientService.remove(id);
    }

    /**
     * 根据主键更新
     *
     * @param sysClientBO 表单
     * @return {@code true} 更新成功，{@code false} 更新失败
     */
    @PutMapping("update")
    @Operation(description = "根据主键更新")
    public boolean update(@RequestBody SysClientBO sysClientBO) {
        return sysClientService.update(sysClientBO);
    }

    /**
     * 条件查询所有数据
     *
     * @return 条件查询所有数据
     */
    @GetMapping("list")
    @Operation(description = "条件查询所有数据")
    public List<SysClientVO> list(SysClientQO sysClientQO) {
        return sysClientService.list(sysClientQO);
    }

    /**
     * 根据主键获取详细信息。
     *
     * @param id 主键
     * @return 详情
     */
    @GetMapping("getInfo/{id}")
    @Operation(description = "根据主键获取")
    public SysClientVO getInfo(@PathVariable Long id) {
        return sysClientService.getInfo(id);
    }

    /**
     * 分页查询
     *
     * @param page 分页对象
     * @return 分页对象
     */
    @GetMapping("page")
    @Operation(description = "分页查询")
    public Page<SysClientVO> page(SysClientQO page) {
        return sysClientService.page(page);
    }

}
